package PlaneGame.CODE;

import javax.sound.sampled.*;
import java.io.File;
import java.io.IOException;

public class YaoBGM extends GameBGM{
    public YaoBGM(String path) {
        super(path);
        try {
            audioInputStream = AudioSystem.getAudioInputStream(new File(path));
            format = audioInputStream.getFormat();
            info = new DataLine.Info(Clip.class, format);
            clip = (Clip) AudioSystem.getLine(info);
            clip.open(audioInputStream);
        } catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) {
            throw new RuntimeException(e);
        }
    }
    @Override
    void fang() {
        try {
            clip.loop(-1);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
